import gpio


class Led:
    def __init__(self, pin_num):
        self.pin_num = pin_num
        self.is_on = False
        v = gpio.gpio_init(self.pin_num)
        # print('gpio_init=',v)
        func = gpio.query_func_value(self.pin_num, 'gpio')
        # print('query_func_value=',v)
        v = gpio.set_func(self.pin_num, func)
        # print('set_func=',v)
        v = gpio.set_dir(self.pin_num, gpio.dir_out)
        v = gpio.set_output(self.pin_num, 0)

    def on(self):
        gpio.set_output(self.pin_num, 1)
        self.is_on = True

    def off(self):
        gpio.set_output(self.pin_num, 0)
        self.is_on = False

    def change(self):
        if self.is_on == True:
            self.off()
        else:
            self.on()
